package moodish.server;

import static org.junit.Assert.*;

import org.junit.Test;

public class FriendshipTest {

	/**
	 * testar os getters da classe Friendship
	 */
	@Test
	public void testGetters() {
		String nickname1 = "Alice";
		String nickname2 = "Ze";
		assertNotNull (nickname1);
		assertNotNull (nickname2);
		Friendship f = new Friendship(nickname1, nickname2);
		assertEquals(nickname1, f.getNickname1());
		assertEquals(nickname2, f.getNickname2());
	}
	
	
	/**
	 *testar a funcao getOtherNickname 
	 */
	@Test
	public void testGetOtherNickname(){
		String nickname1= "Alice";
		String nickname2="Ze";
		assertNotNull (nickname1);
		assertNotNull (nickname2);
		Friendship f = new Friendship (nickname1, nickname2);
		assertEquals(nickname2 , f.getOtherNickname(nickname1));
		assertEquals (nickname1, f.getOtherNickname(nickname2));
		assertEquals (null, f.getOtherNickname("Antonio"));
	}
	
	/**
	 * testar a funcao equals criada na classe friendship
	 */
	@Test
	public void testEquals(){
		String nickname1 = "Alice";
		String nickname2 = "Ze";
		assertNotNull(nickname1);
		assertNotNull (nickname2);
		Friendship f1 = new Friendship (nickname1, nickname2);
		Friendship f4 = new Friendship (nickname1, nickname2);
		Friendship f2 = new Friendship (nickname2, nickname1);
		Friendship f3 = new Friendship ("ana","antonio");
		assertEquals (true,f4.equals(f1));
		assertEquals (true,f2.equals(f1));
		assertEquals(false,f3.equals(f2));
	}
	
	/**
	 *teste ao toString() 
	 */
	@Test
	public void testToString(){
		String nickname1 = "Ana";
		String nickname2 = "Ze";
		assertNotNull(nickname1);
		assertNotNull(nickname2);
		Friendship f1 = new Friendship (nickname1,nickname2);
		assertEquals ("Ana:Ze",f1.toString());
	}

}
